﻿@model IEnumerable<Himall.Web.Areas.Mobile.Models.ProductItem>
@using Himall.Model;
@{
    ViewBag.Title = "商品搜索";
}
@using Himall.Web.Areas.SellerAdmin.Models;

<div class="container">
    @{Html.RenderPartial("~/Areas/Mobile/Templates/Default/Views/Shared/_SearchBox.cshtml");}
    <div class="fixed-box">
        <div class="fixed-inner">
            <a href="javascript:" class="no_icon selected" orderkey="1">默认<i></i></a>
            <a href="javascript:" class="price" orderkey="3">价格<i class="icon_sort"></i></a>
            <a href="javascript:" class="state_switch" orderkey="2">销量<i class="icon_sort_single"></i></a>
            <a href="javascript:" class="state_switch" orderkey="4">评价数<i class="icon_sort_single"></i></a>
            <a href="javascript:" class="switch">&nbsp;<i class="icon_switch"></i></a>
        </div>
    </div>
    <div class="s_found gray">找到相关商品 <span>@ViewBag.Total</span> 件。<a class="search_screen">筛选</a></div>
    <ul class="search-list clearfix" id="searchList">
        @foreach (var product in Model)
        {
            <li productid="@product.Id">
                <a class="p-img" href="javascript:;"><img class="lazyload" src="~/Areas/Mobile/Templates/Default/images/blank.gif" data-url="@product.ImageUrl" alt=""></a>
                <h3><a>@product.Name</a></h3>
                <p class="red">¥@product.SalePrice.ToString("F2")</p>
                <p>@(product.CommentsCount)人评价</p>
            </li>
        }
    </ul>

    <div class="screen">
        <div class="screen_hd clearfix">
            <a class="btn btn-default btn-sm cancel pull-left">取消</a>
            筛选
            <a class="btn btn-primary btn-sm enter pull-right" id="filterSearch">确认</a>
        </div>
        <div class="screen_bd">
            @if (ViewBag.Category != null)
            {
                var categories = ((IEnumerable<Himall.Web.Areas.SellerAdmin.Models.CategoryJsonModel>)ViewBag.Category);
                if (categories.Count() > 0)
                {
                    <ul class="list-group">
                        <li class="list-group-item">
                            分类<span class="glyphicon glyphicon-menu-down"></span><em>全部分类</em>
                            <ol>
                                @foreach (var item in categories)
                                {
                                    foreach (var subItem in item.SubCategory)
                                    {
                                        <li key="cid" valueaa="@subItem.Id"><span>@subItem.Name</span><i class="glyphicon glyphicon-ok"></i></li>
                                    }
                                }
                            </ol>
                        </li>
                    </ul>
                }
            }

            @if (null != ViewBag.Brands)
            {
                var brands = (IEnumerable<BrandInfo>)ViewBag.Brands;
                if (brands.Count() > 0)
                {
                    <ul class="list-group">
                        <li class="list-group-item">
                            品牌<span class="glyphicon glyphicon-menu-down"></span><em>全部品牌</em>
                            <ol>
                                @foreach (var brand in brands)
                                {
                                    <li key="b_id" valueaa="@brand.Id"><span>@brand.Name</span><i class="glyphicon glyphicon-ok"></i></li>
                                }
                            </ol>
                        </li>
                    </ul>
                }
            }

            @if (null != ViewBag.Attrs)
            {

                foreach (var attr in ((IEnumerable<TypeAttributesModel>)ViewBag.Attrs))
                {
                    bool isbreak = false;
                    foreach (var val in ((Dictionary<string, string>)ViewBag.AttrDic).Values)
                    {
                        var ids = val.Replace('@', '_').Split('_');
                        if (ids.Contains(attr.AttrId.ToString()))
                        {
                            isbreak = true;
                            break;
                        }
                    }
                    if (isbreak) { continue; }
                    <ul class="list-group">
                        <li class="list-group-item">
                            @attr.Name<span class="glyphicon glyphicon-menu-down"></span><em>全部@(attr.Name)</em>
                            <ol>
                                @foreach (var attrV in attr.AttrValues)
                                {
                                    <li key="a_id" valueaa="@(attr.AttrId)_@(attrV.Id +ViewBag.a_id)"><span>@attrV.Name</span><i class="glyphicon glyphicon-ok"></i></li>
                                }
                            </ol>
                        </li>
                    </ul>
                }
            }

            <a class="btn btn-default btn-block">清除选项</a>

        </div>
    </div>
    @*<div class="cover"></div>*@

    <div class="loading" id="autoLoad"><span></span></div>
    @*@{Html.RenderPartial("~/Areas/Mobile/Templates/Default/Views/Shared/_4ButtonsFoot.cshtml");}*@

</div>



<a class="WX-backtop" href="#"></a>
<script src="~/Areas/Mobile/Templates/Default/Scripts/productSearch.js"></script>


